home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / CodeWarrior Lite / Metrowerks C⁄C++ Lite / Headers / Universal Headers 2.0.1f / CTBUtilities.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-22  |  6.7 KB  |  277 lines  |  [TEXT/MMCC]

  1. /*
  2.      File:        CTBUtilities.h
  3.  
  4.      Contains:    Communications Toolbox Utilities interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __CTBUTILITIES__
  21. #define __CTBUTILITIES__
  22.  
  23.  
  24. #ifndef __MEMORY__
  25. #include <Memory.h>
  26. #endif
  27. /*    #include <Types.h>                                            */
  28. /*        #include <ConditionalMacros.h>                            */
  29. /*    #include <MixedMode.h>                                        */
  30.  
  31. #ifndef __DIALOGS__
  32. #include <Dialogs.h>
  33. #endif
  34. /*    #include <Errors.h>                                            */
  35. /*    #include <Windows.h>                                        */
  36. /*        #include <Quickdraw.h>                                    */
  37. /*            #include <QuickdrawText.h>                            */
  38. /*        #include <Events.h>                                        */
  39. /*            #include <OSUtils.h>                                */
  40. /*        #include <Controls.h>                                    */
  41. /*            #include <Menus.h>                                    */
  42. /*    #include <TextEdit.h>                                        */
  43.  
  44. #ifndef __STANDARDFILE__
  45. #include <StandardFile.h>
  46. #endif
  47. /*    #include <Files.h>                                            */
  48.  
  49. #ifndef __APPLETALK__
  50. #include <AppleTalk.h>
  51. #endif
  52.  
  53. #ifdef __cplusplus
  54. extern "C" {
  55. #endif
  56.  
  57. #if PRAGMA_ALIGN_SUPPORTED
  58. #pragma options align=mac68k
  59. #endif
  60.  
  61. #if PRAGMA_IMPORT_SUPPORTED
  62. #pragma import on
  63. #endif
  64.  
  65.  
  66. enum {
  67. /*    version of Comm Toolbox Utilities    */
  68.     curCTBUVersion                = 2,
  69. /*    Error codes/types    */
  70.     ctbuGenericError            = -1,
  71.     ctbuNoErr                    = 0
  72. };
  73.  
  74. typedef OSErr CTBUErr;
  75.  
  76.  
  77. enum {
  78.     chooseDisaster                = -2,
  79.     chooseFailed,
  80.     chooseAborted,
  81.     chooseOKMinor,
  82.     chooseOKMajor,
  83.     chooseCancel
  84. };
  85.  
  86. typedef unsigned short ChooseReturnCode;
  87.  
  88.  
  89. enum {
  90.     nlOk,
  91.     nlCancel,
  92.     nlEject
  93. };
  94.  
  95. typedef unsigned short NuLookupReturnCode;
  96.  
  97.  
  98. enum {
  99.     nameInclude                    = 1,
  100.     nameDisable,
  101.     nameReject
  102. };
  103.  
  104. typedef unsigned short NameFilterReturnCode;
  105.  
  106.  
  107. enum {
  108.     zoneInclude                    = 1,
  109.     zoneDisable,
  110.     zoneReject
  111. };
  112.  
  113. typedef unsigned short ZoneFilterReturnCode;
  114.  
  115. typedef pascal short (*DialogHookProcPtr)(short item, DialogPtr theDialog);
  116.  
  117. #if GENERATINGCFM
  118. typedef UniversalProcPtr DialogHookUPP;
  119. #else
  120. typedef DialogHookProcPtr DialogHookUPP;
  121. #endif
  122.  
  123. enum {
  124.     uppDialogHookProcInfo = kPascalStackBased
  125.          | RESULT_SIZE(SIZE_CODE(sizeof(short)))
  126.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  127.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(DialogPtr)))
  128. };
  129.  
  130. #if GENERATINGCFM
  131. #define NewDialogHookProc(userRoutine)        \
  132.         (DialogHookUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppDialogHookProcInfo, GetCurrentArchitecture())
  133. #else
  134. #define NewDialogHookProc(userRoutine)        \
  135.         ((DialogHookUPP) (userRoutine))
  136. #endif
  137.  
  138. #if GENERATINGCFM
  139. #define CallDialogHookProc(userRoutine, item, theDialog)        \
  140.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppDialogHookProcInfo, (item), (theDialog))
  141. #else
  142. #define CallDialogHookProc(userRoutine, item, theDialog)        \
  143.         (*(userRoutine))((item), (theDialog))
  144. #endif
  145.  
  146.  
  147. enum {
  148. /*    Values for hookProc items        */
  149.     hookOK                        = 1,
  150.     hookCancel                    = 2,
  151.     hookOutline                    = 3,
  152.     hookTitle                    = 4,
  153.     hookItemList                = 5,
  154.     hookZoneTitle                = 6,
  155.     hookZoneList                = 7,
  156.     hookLine                    = 8,
  157.     hookVersion                    = 9,
  158.     hookReserved1                = 10,
  159.     hookReserved2                = 11,
  160.     hookReserved3                = 12,
  161.     hookReserved4                = 13,
  162. /*    "virtual" hookProc items    */
  163.     hookNull                    = 100,
  164.     hookItemRefresh                = 101,
  165.     hookZoneRefresh                = 102,
  166.     hookEject                    = 103,
  167.     hookPreflight                = 104,
  168.     hookPostflight                = 105,
  169.     hookKeyBase                    = 1000
  170. };
  171.  
  172. /*    NuLookup structures/constants    */
  173. struct NLTypeEntry {
  174.     Handle                            hIcon;
  175.     Str32                            typeStr;
  176. };
  177. typedef struct NLTypeEntry NLTypeEntry;
  178.  
  179. typedef NLTypeEntry NLType[4];
  180.  
  181. struct NBPReply {
  182.     EntityName                        theEntity;
  183.     AddrBlock                        theAddr;
  184. };
  185. typedef struct NBPReply NBPReply;
  186.  
  187. typedef pascal short (*NameFilterProcPtr)(EntityName *theEntity);
  188.  
  189. #if GENERATINGCFM
  190. typedef UniversalProcPtr NameFilterUPP;
  191. #else
  192. typedef NameFilterProcPtr NameFilterUPP;
  193. #endif
  194.  
  195. enum {
  196.     uppNameFilterProcInfo = kPascalStackBased
  197.          | RESULT_SIZE(SIZE_CODE(sizeof(short)))
  198.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(EntityName*)))
  199. };
  200.  
  201. #if GENERATINGCFM
  202. #define NewNameFilterProc(userRoutine)        \
  203.         (NameFilterUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppNameFilterProcInfo, GetCurrentArchitecture())
  204. #else
  205. #define NewNameFilterProc(userRoutine)        \
  206.         ((NameFilterUPP) (userRoutine))
  207. #endif
  208.  
  209. #if GENERATINGCFM
  210. #define CallNameFilterProc(userRoutine, theEntity)        \
  211.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppNameFilterProcInfo, (theEntity))
  212. #else
  213. #define CallNameFilterProc(userRoutine, theEntity)        \
  214.         (*(userRoutine))((theEntity))
  215. #endif
  216.  
  217. typedef pascal short (*ZoneFilterProcPtr)(ConstStr32Param theZone);
  218.  
  219. #if GENERATINGCFM
  220. typedef UniversalProcPtr ZoneFilterUPP;
  221. #else
  222. typedef ZoneFilterProcPtr ZoneFilterUPP;
  223. #endif
  224.  
  225. enum {
  226.     uppZoneFilterProcInfo = kPascalStackBased
  227.          | RESULT_SIZE(SIZE_CODE(sizeof(short)))
  228.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ConstStr32Param)))
  229. };
  230.  
  231. #if GENERATINGCFM
  232. #define NewZoneFilterProc(userRoutine)        \
  233.         (ZoneFilterUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppZoneFilterProcInfo, GetCurrentArchitecture())
  234. #else
  235. #define NewZoneFilterProc(userRoutine)        \
  236.         ((ZoneFilterUPP) (userRoutine))
  237. #endif
  238.  
  239. #if GENERATINGCFM
  240. #define CallZoneFilterProc(userRoutine, theZone)        \
  241.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppZoneFilterProcInfo, (theZone))
  242. #else
  243. #define CallZoneFilterProc(userRoutine, theZone)        \
  244.         (*(userRoutine))((theZone))
  245. #endif
  246.  
  247. typedef NameFilterProcPtr nameFilterProcPtr;
  248.  
  249. typedef ZoneFilterProcPtr zoneFilterProcPtr;
  250.  
  251. extern pascal CTBUErr InitCTBUtilities(void);
  252. extern pascal short CTBGetCTBVersion(void);
  253. extern pascal short StandardNBP(Point where, ConstStr255Param prompt, short numTypes, NLType typeList, NameFilterUPP nameFilter, ZoneFilterUPP zoneFilter, DialogHookUPP hook, NBPReply *theReply);
  254. extern pascal short CustomNBP(Point where, ConstStr255Param prompt, short numTypes, NLType typeList, NameFilterUPP nameFilter, ZoneFilterUPP zoneFilter, DialogHookUPP hook, long userData, short dialogID, ModalFilterUPP filter, NBPReply *theReply);
  255. #if OLDROUTINENAMES
  256. #define NuLookup(where, prompt, numTypes, typeList, nameFilter, zoneFilter, hook, theReply)  \
  257.     StandardNBP(where, prompt, numTypes, typeList, nameFilter, zoneFilter,  \
  258.     hook, theReply)
  259. #define NuPLookup(where, prompt, numTypes, typeList, nameFilter, zoneFilter, hook, userData, dialogID, filter, theReply)  \
  260.     CustomNBP(where, prompt, numTypes, typeList, nameFilter,  \
  261.     zoneFilter, hook, userData, dialogID, filter, theReply)
  262. #endif
  263.  
  264. #if PRAGMA_IMPORT_SUPPORTED
  265. #pragma import off
  266. #endif
  267.  
  268. #if PRAGMA_ALIGN_SUPPORTED
  269. #pragma options align=reset
  270. #endif
  271.  
  272. #ifdef __cplusplus
  273. }
  274. #endif
  275.  
  276. #endif /* __CTBUTILITIES__ */
  277.